<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    .box{width:100px;height:40px;background: red;}
  </style>
  
</head>
<body>
  <div class="box" onclick="alert('hello 行内js')"></div>
  <br>
  <div class="box box1"></div>
  <br>
  <div class="box box2"></div>
</body>
<script src="./test.js"></script>
<script>
  alert("hello 内部js2");

  function fn(){
    alert("hello 内部js1");
  }

  document.querySelector(".box1").onclick = fn;
  document.querySelector(".box2").onclick = fn;
</script>
</html>